﻿using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using TTGameEngine;

/*
 * BulletEffectScriptEditor
 *
 *
 *
 * 依赖：
 *
 * ！不写重复代码！
 * @author TTun
 * @date 9/21/2017 9:48:18 AM
 */
[CustomEditor(typeof(BulletEffectScript))]
public class BulletEffectScriptEditor : Editor {
    BulletEffectScript script;
    SerializedObject obj;
    SerializedProperty bullet;
    bool isExpend = true;

    void OnEnable() {
        script = target as BulletEffectScript;
        obj = new SerializedObject(target);
        bullet = obj.FindProperty("bulletToEnemy");
    }
    public override void OnInspectorGUI() {
        obj.Update();
        for(int i = 0; i < bullet.arraySize; i++) {
            SerializedProperty property = bullet.GetArrayElementAtIndex(i);
            EditorGUILayout.PropertyField(property, new GUIContent(script.bulletToEnemy[i].bulletTag + " -> " + script.bulletToEnemy[i].enemyTag), true);
        }

        isExpend =  EditorGUILayout.Foldout(isExpend , "All Values");
        if(isExpend) {
            EditorGUI.indentLevel++;
            base.OnInspectorGUI();
            EditorGUI.indentLevel--;
        }
        obj.ApplyModifiedProperties();
    }
}
